import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
    AutoImport({
      resolvers:[ 
        ElementPlusResolver(),
        // 自动导入图标组件
        IconsResolver(),
      ]
    }),
    Components({
      resolvers:[ 
        ElementPlusResolver(),
        // 自动注册图标组件
        IconsResolver({
          // 取消前缀
          prefix:false,
          // 使用element-plus的图标库，图标库名 <ep-图标名>
          enabledCollections: ['ep'],
        }),
      ]
    }),
    Icons({
      autoInstall: true,
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})
